<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>浏览商品 - 拼团商城</title>
    <style>
        body {
            margin: 0;
            padding: 40px;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
            background: linear-gradient(135deg, #f3f4f6, #e2e8f0);
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            animation: fadeInUp 0.6s ease-out forwards;
            opacity: 0;
            transform: translateY(30px);
        }

        @keyframes fadeInUp {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        h2 {
            text-align: center;
            margin-bottom: 30px;
            color: #2e2e2e;
        }

        .category-list {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            margin-bottom: 40px;
        }

        .category {
            background: white;
            border-radius: 12px;
            padding: 10px 20px;
            margin: 10px;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
            transition: all 0.3s;
        }

        .category:hover {
            background: linear-gradient(to right, #667eea, #764ba2);
            color: white;
        }

        .product-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap:100px 24px;
        }

        .product-card {
            background: white;
            border-radius: 16px;
            padding: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
            transition: transform 0.3s;
        }

        .product-card:hover {
            transform: translateY(-5px);
        }

        .product-card img {
            width: 100%;
            border-radius: 12px;
        }

        .product-name {
            font-size: 16px;
            font-weight: bold;
            margin-top: 12px;
            color: #333;
        }

        .product-price {
            color: #764ba2;
            font-size: 15px;
            margin-top: 8px;
        }

        .btn-group {
            display: flex;
            justify-content: space-between;
            margin-top: 12px;
        }

        .btn {
            flex: 1;
            margin: 0 4px;
            padding: 8px;
            font-size: 14px;
            border: none;
            border-radius: 10px;
            color: white;
            background: linear-gradient(to right, #667eea, #764ba2);
            cursor: pointer;
            transition: background 0.3s;
        }

        .btn:hover {
            background: linear-gradient(to right, #5a67d8, #6b46c1);
        }
        .product-image {
            width: 200px;
            height: 200px;
            object-fit: cover;
        }
</style>
</head>
<body>
<div class="container">
    <div style="background: white;
     padding: 16px 40px;
    display: flex;
     justify-content: space-between;
     align-items: center;
     box-shadow: 0 2px 12px rgba(0,0,0,0.05);
     border-radius: 0 0 20px 20px;">
        <div>
            <a href="${pageContext.request.contextPath}/front/products" style="margin: 0 12px; text-decoration: none; color: #333;">商品浏览</a>
            <a href="${pageContext.request.contextPath}/front/cart" style="margin: 0 12px; text-decoration: none; color: #333;">购物车</a>
            <a href="${pageContext.request.contextPath}/front/order/my" style="margin: 0 12px; text-decoration: none; color: #333;">我的订单</a>
            <a href="${pageContext.request.contextPath}/front/group/my" style="margin: 0 12px; text-decoration: none; color: #333;">我的拼团</a>
        </div>
        <div>
            <a href="${pageContext.request.contextPath}/front/login"
               style="padding: 8px 16px; background: linear-gradient(135deg, #c3aed6, #a393eb); color: white; border-radius: 12px; text-decoration: none; transition: all 0.3s ease;">
                退出登录
            </a>
        </div>
    </div>
    <div class="category-list">
        <c:forEach var="cat" items="${categoryList}">
            <form action="${pageContext.request.contextPath}/front/products" method="get">
                <input type="hidden" name="categoryId" value="${cat.id}" />
                <button class="category">${cat.name}</button>
            </form>
        </c:forEach>
    </div>
    <div class="product-grid">
        <c:forEach var="product" items="${productList}">
            <div class="product-card">
                <img src="${product.imageUrl}" alt="${product.name}" class="product-image" />
                <div class="product-name">${product.name}</div>
                <div class="product-price">￥${product.price}</div>
                <div class="btn-group">
                    <form action="${pageContext.request.contextPath}/front/product/detail" method="get">
                        <input type="hidden" name="id" value="${product.id}" />
                        <button class="btn">详情</button>
                    </form>
                    <form action="${pageContext.request.contextPath}/front/cart/add" method="post">
                        <input type="hidden" name="productId" value="${product.id}" />
                        <input type="hidden" name="quantity" value="1" />
                        <button class="btn">加入购物车</button>
                    </form>
                </div>
            </div>
        </c:forEach>
    </div>


</div>
</body>
</html>